package object_oriented;


import object_oriented.Person;

public class Test {
    public static void main (String []args){
        Person p  = new Person("zhangsan") ;
        p.son.age = "20" ;
        try {
            Object clone = p.clone();
            if( clone instanceof Person){
                Person o =  (Person)clone;
                System.out.println("克隆完的结果：");
                System.out.println("源的内容");
                System.out.println( p );
                System.out.println( p.getInfo());
                System.out.println("目标的内容");
                System.out.println( o );
                System.out.println( o.getInfo() );
                System.out.println();
                p.son.age = "10" ;
                p.setName("lisi");

                System.out.println("重新给源进行赋值后");
                System.out.println("源的内容");
                System.out.println( p );
                System.out.println( p.getInfo());
                System.out.println("目标的内容");
                System.out.println( o );
                System.out.println( o.getInfo() );
            }
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }


    }
}
